<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">用户帐号</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">{$info.username}</div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">安全邮箱</label>
                <div class="layui-input-block">
                    <input type="email" name="email" value="{$info.email}"  placeholder="请输入安全邮箱，如果不修改请忽略本参数" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">修改密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password"  placeholder="请输入密码，如果不修改请忽略本参数" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">实名认证</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">{$info.is_auth ? '<span class="layui-badge layui-bg-blue">认证成功</span>' : '未认证'}</div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">注册时间</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">{$info.create_time|date="Y-m-d H:i:s"}</div>
                </div>
            </div>

            <hr>

            <div class="layui-form-item">
                <label class="layui-form-label">账户余额</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid">{$info.amount} ￥</div>
                </div>
            </div>

            <hr>

            <div class="layui-form-item">
                <label class="layui-form-label">当前用户组</label>
                <div class="layui-input-block">
                    <select name="group" lay-verify="required">
                        {volist name="$group" id="vo"}
                        <option value="{$vo.id}" {eq name="$info.group" value="$vo.id"}selected{/eq}>{$vo.group_name}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <hr>

            <div class="layui-form-item">
                <label class="layui-form-label">最近登录</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">{:getNotNullTime($info.login_time,'暂无登录信息')}</div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">登录IP地址</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">{$info.login_real_ip|default='暂无登录信息'}</div>
                </div>
            </div>



        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                保存更改
            </button>
        </div>
    </div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
    layui.use(['form','jquery','laydate'],function(){
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        // laydate.render({
        //     elem: '#grade_time',
        //     type:'date'
        // });

        form.on('submit(save)', function(data){
            $.ajax({
                data:JSON.stringify(data.field),
                dataType:'json',
                contentType:'application/json',
                type:'post',
                success:function(res){
                    //判断有没有权限
                    if(res && res.code == 999){
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 2000,
                        })
                        return false;
                    }else if(res.code == 200){
                        layer.msg(res.msg,{icon:1,time:1000},function(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    }else{
                        layer.msg(res.msg,{icon:2,time:1000});
                    }
                }
            })
            return false;
        });

    })
</script>
</body>
</html>